﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using TianYa.API;
using TianYa.Data;

namespace TianYa
{
    public class GloabalData : INotifyPropertyChanged
    {

        public event PropertyChangedEventHandler PropertyChanged;
        private static GloabalData instance;
        public static GloabalData Instance
        {
            get
            {
                //if (instance == null)
                //    instance = new GloabalData();
                return instance;
            }
        }

        public GloabalData()
        {
            if (instance != null)
                throw new Exception("只能有一个实例");//之所以这么做，是因为需要配合绑定
            instance = this;
            this.APIClient = new DefaultClient();
        }

        public DefaultClient APIClient { get; private set; }


        private TianYaDataBase tianYaDataBase;
        public TianYaDataBase TianYaDataBase
        {
            get
            {
                if (tianYaDataBase == null)
                    tianYaDataBase = new TianYaDataBase();
                return tianYaDataBase;
            }
        }
    }
}
